import request from '@/utils/request'

export function getList(query) {
  return request({
    url: '/sysm/dept/listTableTree',
    method: 'get',
    params: query
  })
}

export function getDeptTypes(query) {
  return request({
    url: '/sysm/dept/deptTypes',
    method: 'get',
    params: query
  })
}

export function getListTree(query) {
  return request({
    url: '/sysm/dept/listTree',
    method: 'get',
    params: query
  })
}

// 根据部门类型查询已启用部门
export function getListTreeByType(query) {
  return request({
    url: '/sysm/dept/listTreeByType',
    method: 'get',
    params: query
  })
}

export function getListAllTree(query) {
  return request({
    url: '/sysm/dept/listAllTree',
    method: 'get',
    params: query
  })
}

export function getSiteByDeptId(query) {
  return request({
    url: `/basic/deptSite/`,
    method: 'get',
    params: query
  })
}

export function saveOrUpdate(param) {
  return request.post('/sysm/dept/', JSON.stringify(param))
}

export function saveOrUpdateSite(param) {
  return request.post('/basic/deptSite/', JSON.stringify(param))
}

export function deleteById(id) {
  return request({
    url: `/sysm/dept/${id}`,
    method: 'delete'
  })
}

export function deleteSiteById(param) {
  return request({
    url: `/basic/deptSite/${param}`,
    method: 'delete'
  })
}

// 查询已启用的科室
export function getKeyWorkDept(query) {
  return request({
    url: '/sysm/dept/userDeptTree',
    method: 'get',
    params: query
  })
}

// 导入
export function upload(data) {
  const config = {
    'Content-Type': 'multipart/form-data'
  }
  return request({
    url: `/sysm/dept/uploadExcel`,
    method: 'post',
    data: data,
    headers: config
  })
}

export function getListPowerSupplySec(query) {
  return request({
    noToken: 'cms',
    url: '/sysm/wlmqcms/quota/listPowerSupplySec',
    method: 'get',
    params: query
  })
}

// 根据登陆人查询部门
export function getCommonDeptList(query) {
  return request({
    url: '/sysm/dept/deptList',
    method: 'get',
    params: query
  })
}
